import com.gamejelly.proxy.client.LoadBalance;
import com.gamejelly.proxy.client.ProxyUtil;
import com.gamejelly.srv.domain.Student;
import com.gamejelly.srv.service.Test;

import java.util.HashMap;
import java.util.concurrent.ExecutionException;

public class BenchMark {

    public static final int nums = 50_000;

    public static void main(String[] args) throws ExecutionException, InterruptedException {


        Test test = ProxyUtil.serviceProxy(LoadBalance.RANDOM, Test.class, "127.0.0.1:9321", "127.0.0.1:9322");
        Student student = new Student();
        student.setId(1);
        student.setName("xm");
        student.setScore(100);
        HashMap<Integer, Integer> map = new HashMap<>(6);
        map.put(1, 1);
        map.put(2, 1);
        map.put(3, 1);
        map.put(4, 1);
        for (int i = 0; i < nums; i++) {
            test.req(student, map);
        }

        System.out.println("预热结束");

        long start = System.currentTimeMillis();
        for (int j = 0; j < nums; j++) {
            test.req(student, map);
        }
        System.out.println("cost : " + (System.currentTimeMillis() - start) + "ms");
    }

}
